package me.ilich.piet.interpreter;

import me.ilich.piet.interpreter.Colourable;
import me.ilich.piet.interpreter.elements.Block;
import junit.framework.TestCase;

public class BlockTestCase extends TestCase {
	
	private Block br(int b){
		Block block = new Block();
		block.setLightness(b);
		return block;
	}
	
	private Block cl(int c){
		Block block = new Block();
		block.setHue(c);
		return block;
	}	
	
	public void testBrightnessDif(){
		assertEquals(0, ColoursCompare.brightnessDif(br(Colourable.LIGHT), br(Colourable.LIGHT)));
		assertEquals(1, ColoursCompare.brightnessDif(br(Colourable.LIGHT), br(Colourable.NORMAL)));
		assertEquals(2, ColoursCompare.brightnessDif(br(Colourable.LIGHT), br(Colourable.DARK)));
		assertEquals(2, ColoursCompare.brightnessDif(br(Colourable.NORMAL), br(Colourable.LIGHT)));
		assertEquals(0, ColoursCompare.brightnessDif(br(Colourable.NORMAL), br(Colourable.NORMAL)));
		assertEquals(1, ColoursCompare.brightnessDif(br(Colourable.NORMAL), br(Colourable.DARK)));
		assertEquals(1, ColoursCompare.brightnessDif(br(Colourable.DARK), br(Colourable.LIGHT)));
		assertEquals(2, ColoursCompare.brightnessDif(br(Colourable.DARK), br(Colourable.NORMAL)));
		assertEquals(0, ColoursCompare.brightnessDif(br(Colourable.DARK), br(Colourable.DARK)));		
	}
	
	public void testColorDif(){
		assertEquals(0, ColoursCompare.colorDif(cl(Colourable.RED), cl(Colourable.RED)));
		assertEquals(1, ColoursCompare.colorDif(cl(Colourable.RED), cl(Colourable.YELLOW)));
		assertEquals(2, ColoursCompare.colorDif(cl(Colourable.RED), cl(Colourable.GREEN)));
		assertEquals(3, ColoursCompare.colorDif(cl(Colourable.RED), cl(Colourable.CYAN)));
		assertEquals(4, ColoursCompare.colorDif(cl(Colourable.RED), cl(Colourable.BLUE)));
		assertEquals(5, ColoursCompare.colorDif(cl(Colourable.RED), cl(Colourable.MAGENTA)));
	}

}
